package com.qqserver.service;

import com.qqcommon.Message;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

/**
 *
 * 该类的一个对象和客户端保持通信
 */

public class ServerConnectClientThread extends Thread{
    //必须持有socket
    private Socket socket;
    private String userId;//连接到服务器端的用户的用户名

    public ServerConnectClientThread(Socket socket, String userId) {
        this.socket = socket;
        this.userId = userId;
    }

    @Override
    public void run() {
        while(true){
            try {
                System.out.println("服务端和客户端保持通信,读取数据....");
                ObjectInputStream ois=new ObjectInputStream(socket.getInputStream());
                Message message=(Message)ois.readObject();
                //后面会使用

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
